package com.example.service;

import com.example.task.AsyncTask;
import com.example.util.IpUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;

@Service
public class AsyncTaskService {


    private static final Logger logger = LoggerFactory.getLogger(AsyncTaskService.class);

    @Autowired
    private AsyncTask asyncTask;
    @Autowired
    private HttpServletRequest request;

    public void showMsg() throws InterruptedException {
        asyncTask.showMessage(IpUtils.getIpAddr(request));
    }


    public void showMessage() throws InterruptedException {
        int i = 10;
        while (i >= 0) {
            logger.info("=====================================================");
            Thread.sleep(1000L);
            i--;
        }
    }

}
